import random


def generate_test_cases(num_cases=5):
    """
    生成测试用例
    :param num_cases: 生成的测试用例数量
    :return: 测试用例列表（每个用例包含 g, s 和预期输出）
    """
    test_cases = [
        # 示例用例
        {"g": [1, 2, 3], "s": [1, 1], "expected": 1},
        {"g": [1, 2], "s": [1, 2, 3], "expected": 2},
        # 边界用例
        {"g": [], "s": [1, 2], "expected": 0},
        {"g": [1, 2], "s": [], "expected": 0},
        {"g": [3, 4], "s": [1, 2], "expected": 0},
        # 随机用例
    ]

    # 生成随机测试用例
    for _ in range(num_cases):
        max_val = random.randint(1, 10)
        g_len = random.randint(0, 10)
        s_len = random.randint(0, 10)
        g = [random.randint(1, max_val) for _ in range(g_len)]
        s = [random.randint(1, max_val) for _ in range(s_len)]
        # 计算预期输出（使用正确逻辑预处理）
        sorted_g = sorted(g)
        sorted_s = sorted(s)
        i = j = count = 0
        while i < len(sorted_g) and j < len(sorted_s):
            if sorted_s[j] >= sorted_g[i]:
                count += 1
                i += 1
                j += 1
            else:
                j += 1
        test_cases.append({
            "g": g,
            "s": s,
            "expected": count
        })
    return test_cases